Sample Code - DatabaseTable Object

This sample code shows the use of DatabaseTable Object. Modify the following sample code to fit your needs.

Private Sub Command1_Click()
On Error GoTo Command1_Click_Error

Dim crystalApplication As CRPEAuto.Application
Dim crystalReport As CRPEAuto.Report
Dim db As CRPEAuto.Database
Dim dbtables As CRPEAuto.DatabaseTables
Dim dbTable As CRPEAuto.DatabaseTable
Dim dbFields As CRPEAuto.DatabaseFieldDefinitions
Dim dbField As CRPEAuto.DatabaseFieldDefinition

Set crystalApplication = CreateObject("Crystal.CRPE.Application")
Set crystalReport = crystalApplication.OpenReport _
    ("d:\crw\reports\craze\wwsales.rpt")

Set db = crystalReport.Database
Set dbtables = db.Tables
'find the alias name of the first table in the database
If dbtables.Count >= 1 Then
Set dbTable = dbtables.Item(1)
Set dbFields = dbTable.Fields
Set dbField = dbFields.Item(1)
MsgBox "Table Alias Name is <" + dbField.TableAliasName + ">"
End If

Command1_Click_Exit:
Exit Sub

Command1_Click_Error:
If crystalApplication Is Nothing Then
MsgBox "Unable to CreateObject(""Crystal.CRPE.Application"")"
GoTo Command1_Click_Exit
End If
If crystalReport Is Nothing Then
MsgBox "Unable to OpenReport(""d:\crw\reports\craze\wwsales.rpt"")"
GoTo Command1_Click_Exit
End If
MsgBox "Unknown error in Command1_Click routine"
GoTo Command1_Click_Exit
End Sub


Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com